import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import 'pos_link_print_platform_interface.dart';

/// An implementation of [PosLinkPrintPlatform] that uses method channels.
class MethodChannelPosLinkPrint extends PosLinkPrintPlatform {
  /// The method channel used to interact with the native platform.
  @visibleForTesting
  final methodChannel = const MethodChannel('pos_link_print');

  @override
  Future<String?> getPlatformVersion() async {
    final version = await methodChannel.invokeMethod<String>('getPlatformVersion');
    return version;
  }

  /*
  清空打印机缓存
   */
  @override
  Future<void> clear() async{
    await methodChannel.invokeMethod('clear');
  }
  /*
  左对齐
   */
  @override
  Future<void> leftAlign() async{
    await methodChannel.invokeMethod('leftAlign');
  }
  /*
  右对齐
   */
  @override
  Future<void> rightAlign() async{
    await methodChannel.invokeMethod('rightAlign');
  }
  /*
  居中对齐
   */
  @override
  Future<void> centerAlign() async{
    await methodChannel.invokeMethod('centerAlign');
  }
  /*
  设置文字
   */
  @override
  Future<void> content(String content) async{
    await methodChannel.invokeMethod('content',{
      "content":content,
    });
  }
  /*
  二维码 条形码
  type 条形码类型 1 - 7
  blockSize 条形码大小
  content 条形码内容
   */
  @override
  Future<void> barcode(int type,int blockSize,String content) async{
    await methodChannel.invokeMethod('barcode',{
      "type":type,
      "blockSize":blockSize,
      "content":content,
    });
  }
  /*
  小字体
   */
  @override
  Future<void> smallFont() async{
    await methodChannel.invokeMethod('smallFont');
  }
  /*
  正常的字体
   */
  @override
  Future<void> normalFont() async{
    await methodChannel.invokeMethod('normalFont');
  }
  /*
  大字体
   */
  @override
  Future<void> bigFont() async{
    await methodChannel.invokeMethod('bigFont');
  }
  /*
  页头分割线
   */
  @override
  Future<void> header() async{
    await methodChannel.invokeMethod('header');
  }
  /*
    页脚分割线
   */
  @override
  Future<void> trailer() async{
    await methodChannel.invokeMethod('trailer');
  }
  /*
    免责声明
   */
  @override
  Future<void> disclaimer() async{
    await methodChannel.invokeMethod('disclaimer');
  }
  /*
    日期
   */
  @override
  Future<void> date() async{
    await methodChannel.invokeMethod('date');
  }
  /*
    时间
   */
  @override
  Future<void> time() async{
    await methodChannel.invokeMethod('time');
  }
  /*
    sn
   */
  @override
  Future<void> sn() async{
    await methodChannel.invokeMethod('sn');
  }
  /*
    invert
   */
  @override
  Future<void> invert() async{
    await methodChannel.invokeMethod('invert');
  }
  /*
    行分隔符
   */
  @override
  Future<void> lineSeparator() async{
    await methodChannel.invokeMethod('lineSeparator');
  }
  /*
    打印
   */
  @override
  Future<void> print() async{
    await methodChannel.invokeMethod('print');
  }
  /*
    打印图片
   */
  @override
  Future<void> printImg(Uint8List bytes,int location) async{
    await methodChannel.invokeMethod('printImg',{
      "imgBytes":bytes,
      "location":location
    });
  }

}
